﻿using System;
using System.Threading;
class Program
{
  static void Main(string[] args)
  {

  }

}
// 时间信息 命名规范 - 事件名 + EventArgs
public class OrderEventArgs : EventArgs
{
  public string DishName { get; set; }
  public string Size { get; set; }
}
public delegate void OrderEventHandler(Customer customer, OrderEventArgs e);
public class Customer
{
  public OrderEventHandler orderEventHandler;
  public event OrderEventHandler Order
  {
    add
    {
      this.orderEventHandler = value;
    }
    remove
    {
      this.orderEventHandler = value;
    }
  }
  public double Bill { get; set; }
  public void PayTheBill()
  {
    Console.WriteLine("I will pay ${0}", this.Bill);
  }
  public void WalkIn()
  {
    Console.WriteLine("Walk into the restaurant.");
  }
  public void SitDown()
  {
    Console.WriteLine("Sit down");
  }
  public void Think()
  {
    for (int i = 0; i < 5; i++)
    {
      Console.WriteLine("Let me think...");
      Thread.Sleep(1000);
    }
    if (orderEventHandler != null)
    {
      OrderEventArgs e = new OrderEventArgs();
      e.DishName = "Kongpao Chicken";
      e.Size = "large";
      //触发事件处理器
      this.orderEventHandler.Invoke(this, e);
    }
  }
  public void Action()
  {
    Console.ReadLine();
    this.WalkIn();
    this.SitDown();
    this.Think();
  }
}

public class Waiter
{
  internal void Action(Customer customer, OrderEventArgs e)
  {
    Console.WriteLine("I will serve you the dish {0}", e.DishName);
    double price = 10;
    switch (e.Size)
    {
      case "small":
        price *= 0.5;
        break;
      case "large":
        price *= 1.5;
        break;
      default:
        break;
    }
    customer.Bill += price;
  }
}